#include<bits/stdc++.h>
using namespace std;
int T;
int n,m;
int num;
double l,v;
struct Car{
    double d,v,a;
    int closest_camera=-1;
    double l,r;
    bool detect,del;
}car[100005];
double p[100005];
int compare0(double x)
{
    if(x>0) return 1;
    if(x<0) return -1;
    return 0;
}
bool cmp(Car a,Car b)
{
    if(compare0(a.a)==compare0(b.a))
    {
        return a.d<b.d;
    }
    else
    {
        return a.a<b.a;
    }
}
bool rgcmp(Car a,Car b)
{
    return a.r<b.r;
}
int work1()
{
    sort(p+1,p+m+1);
    sort(car+1,car+n+1,cmp);
    int pos1=1,pos2=1;
    while(1)
    {
        if(car[pos1].a>=0||pos1>n||pos2>m) break;
        if(car[pos1].d<=p[pos2])
        {
            if(sqrt(car[pos1].v*car[pos1].v+2*car[pos1].a*(p[pos2]-car[pos1].d))>v)
            {
                car[pos1].closest_camera=pos2;
            }
            pos1++;
        }
        else
        {
            pos2++;
        }
    }
    int ans11=0,ans12=0;
    for(int i=1;i<=n;i++)
    {
        double speed=-1;
        if(car[i].a>=0)
        {
            if(car[i].d<=p[m])
            {
                speed=sqrt(car[i].v*car[i].v+2*car[i].a*(p[m]-car[i].d));
                if(speed>v)
                {
                    ans11++;
                    car[i].detect=1;
                }
            }
        }
        else
        {
            int cc=car[i].closest_camera;
            if(cc!=-1)
            {
                speed=sqrt(car[i].v*car[i].v+2*car[i].a*(p[cc]-car[i].d));
                if(speed>v)
                {
                    ans12++;
                    car[i].detect=1;
                }
            }
        }
    }
    return ans11+ans12;
}
int work2()
{
    bool k=1;
    for(int i=1;i<=n;i++)
    {
        if(car[i].a<0)
        {
            k=0;
        }
    }
    if(k)
    {
        return m-(num!=0);
    }
    for(int i=1;i<=n;i++)
    {
        if(car[i].v>v&&car[i].a>=0)
        {
            car[i].l=car[i].d;
            car[i].r=l;
        }
        if(car[i].v>v&&car[i].a<0)
        {
            car[i].l=car[i].d;
            car[i].r=car[i].d+(v*v-car[i].v*car[i].v)/car[i].a/2.0-1e-9;
        }
        if(car[i].v==v&&car[i].a>0)
        {
            car[i].l=car[i].d+1e-9;
            car[i].r=l;
        }
        if(car[i].v<v&&car[i].a>0)
        {
            car[i].l=car[i].d+(v*v-car[i].v*car[i].v)/car[i].a/2.0+1e-9;
            car[i].r=l;
        }
    }
    int ans2=0,pos=0;
    sort(car+1,car+n+1,rgcmp);
    while(pos<=m)
    {   
        pos++;
        double rt=1e18;
        for(int j=1;j<=n;j++)
        {
            if(!car[j].detect||car[j].del) continue;
            rt=min(rt,car[j].r);
        }
        //cout<<"222"<<rt<<endl;
        if(p[pos]<=rt && (p[pos+1]>rt||pos==m))
        {
            ans2++;
            //cout<<"111"<<pos<<endl;
            for(int j=1;j<=n;j++)
            {
                if(!car[j].detect||car[j].del) continue;
                if(car[j].l<=p[pos]&&p[pos]<=car[j].r)
                {
                    car[j].del=1;
                }
            }
        }
    }
    return m-ans2;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
            car[i].closest_camera=-1;
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        num=work1();
        cout<<num<<' '<<work2()<<endl;
    }
	return 0;
}